<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>
        统计字符串中每个字符的个数？
        var str = 'abcdacbabcbababcbabcabd'

        // 结果
        // { a: 出现次数， b: 出现次数, ...}
    </div>
    <script>
        function CountChar ( str , a ) {
            var count = 0 ;
            for ( var i = 0 ; i < str.length ; i ++ ) {
                if ( str[i] == a ) {
                    count ++ ;
                }
            }
            var res = "含有字符" + a + count + "个" ; 
            return res ; 
        }
        function noRepeatChar( str ) {
            var arr = str.split("");
            var set = new Set(arr);
            return Array.from(set).join("");
        }
        var str = 'abcdacbabcbababcbabcabd' ; 
        var str2 = noRepeatChar(str);
        for( var i = 0 ; i < str2.length ; i ++ ) {
            console.log(CountChar(str,str2[i]));
        }
        console.log("一共有" + str.length + "个字符");
    </script>
</body>
</html>